package com.googlecode.cswish.struts.conversion;

import javax.annotation.Resource;

import com.googlecode.cswish.model.PageElement;

/**
 * Override the default template name
 * 
 * @author feng Date: 2009-2-21
 *
 */
@Resource(shareable=false)
public class FtlPageConverter implements ElementConverter {
	
	@Resource
	protected ModelPageConverter modelPageConverter;
	
	private String templateName;
	
	public FtlPageConverter() {
		
	}
	
	public void setTemplateName(String templateName) {
		this.templateName = templateName;
	}
	
	public String getTemplateName() {
		return templateName;
	}

	@Override
	public PageElement convert(ConversionContext context) {
		PageElement pageElement = modelPageConverter.convert(context);
		if (pageElement != null) {
			pageElement.setType(this.templateName);
		}
		return pageElement;
	}
}